package com.shuai.jit.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shuai.jit.entity.user.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author joker
 * @since 2021-01-21
 */
@Mapper
@Repository
public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据用户名获取对象
     * @param username
     * @return
     */
    @Select("select * from user where username=#{username} ")
    User selectByName(String username);

    /**
     * 查找是否由此用户
     * @param telephone
     * @param username
     * @return
     */
    @Select("select * from user where user_telephone=#{telephone} or username=#{username}")
    User selectRegister(String telephone,String username);

    @Select("select * from user where user_telephone=#{telephone}")
    User selectByTelephone(String telephone);

    @Select("select * from user where id not in (select friend_id from friend where user_id=#{userId})")
    List<User> selectAddAllFriend(String userId);

    @Select("SELECT id,username,user_email,user_introduce,user_img FROM user where id=#{userId} ")
    User getUserInfo(String userId);
}
